<template>
  <div>
    <el-popover placement="bottom-start" trigger="click"  > 
      <el-form :inline="true" label-width="90px" :model="searchList" class="search-panle">
        <el-form-item label="卡号">
          <el-input v-model="searchList.cardId"  ></el-input>
        </el-form-item>
        <el-form-item label="身份证"><el-input v-model="searchList.idNo"  ></el-input></el-form-item>
        <el-form-item label="电话"><el-input v-model="searchList.phone"></el-input></el-form-item>
        <el-form-item label="姓名"><el-input v-model="searchList.providerName"></el-input></el-form-item>
        <el-form-item label="性别">
          <el-select v-model="searchList.sex" >
            <el-option value="" label="【空】"></el-option>
            <el-option :value="1" label="男"></el-option>
            <el-option :value="2" label="女"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="血型" ><el-select v-model="searchList.bloodType"><el-option value="" label="【空】"></el-option><el-option v-for="item in bloodTypeList" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
        <el-form-item label="浆员状态" ><el-select v-model="searchList.providerState" ><el-option value="" label="【空】"></el-option><el-option v-for="item in codeData14" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
        <el-form-item label="介绍人" ><el-input v-model="searchList.jsr" ></el-input></el-form-item>
        <el-form-item label="地址"><el-input v-model="searchList.address" ></el-input></el-form-item>
        <el-form-item label="身份证地址"><el-input v-model="searchList.idNoAddress" ></el-input></el-form-item>
        <el-form-item label="创建时间" ><el-date-picker v-model="searchList.time"  type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" align="right"></el-date-picker></el-form-item>
      <el-button type="primary" @click="submitSearchData" >提交</el-button>
      </el-form>
      <el-button slot="reference" type="primary">查询</el-button>
    </el-popover>
    <el-button type="primary" @click="dialogShow('insert')">添加</el-button>
            <!-- 表格 -->
        <el-table :data="tableData" stripe border class="company-table" :height="tableHeight" style="width: 100%;" v-loading="loading">
            <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
            <el-table-column prop="icon" label="头像"  min-width="75"><template slot-scope="scope">
                <img :src="scope.row.photo" style="width: 25px;height:30px"></template>
            </el-table-column>
            <el-table-column prop="cardId" label="卡号" sortable min-width="80"></el-table-column>
            <el-table-column prop="name" label="姓名" sortable min-width="80"></el-table-column>
            <el-table-column prop="sex" label="性别" :formatter="formatSex" sortable min-width="75"></el-table-column>
            <el-table-column prop="age" label="年龄" sortable min-width="75"></el-table-column>
            <el-table-column prop="idNo" label="身份证号" sortable min-width="180"></el-table-column>
            <el-table-column prop="createDate" label="创建日期" sortable min-width="170"></el-table-column>
            <el-table-column prop="createNurseName" label="创建护士" sortable min-width="110"></el-table-column>
            <el-table-column prop="phone" label="电话" sortable min-width="120"></el-table-column>
            <el-table-column prop="idNoAddress" label="地址" sortable min-width="350"></el-table-column>
            <el-table-column prop="introducer" label="介绍人" sortable min-width="100"></el-table-column>
            <el-table-column fixed="right" label="操作" align="center" min-width="75">
                <template slot-scope="scope">
                    <el-button  @click="dialogShow('updata',scope.row)" type="text" size="small">编辑</el-button>
                </template>
            </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>
    <el-dialog :title="dialog1.title" :visible.sync="dialog1.isShow" width="1050px" top="60px" :close-on-click-modal="false" class="dialog-form" v-dialogDrag>
      <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="基础信息" name="first">
          <h3 class="dialog-plate-title"><span>基本信息</span></h3>
          <el-row :gutter="20">
            <el-col :span="18">
              <el-form :inline="true" :model="dialogList" ref="dialogRefs" :rules="dialogRules" label-width="120px" >
                <el-form-item label="卡号" prop="cardId" v-if="dialog1.title!=='添加'" ><el-input v-model="dialogList.cardId"></el-input></el-form-item>
                <el-form-item label="姓名" prop="name"><el-input v-model="dialogList.name" :disabled="dialog1.title!=='添加'"></el-input></el-form-item>
                <el-form-item label="身份证号" prop="idNo"><el-input v-model="dialogList.idNo" :disabled="dialog1.title!=='添加'"></el-input></el-form-item>
                <el-form-item label="出生日期" prop="birthday"><el-date-picker v-model="dialogList.birthday" disabled type="date" placeholder="选择日期"></el-date-picker></el-form-item>
                <el-form-item label="年龄" prop="age"><el-input v-model="dialogList.age" disabled></el-input></el-form-item>
                <el-form-item label="性别" prop="sex"><el-select v-model="dialogList.sex" disabled class="select200"><el-option v-for="item in sexList" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="电话"><el-input v-model="dialogList.phone"></el-input></el-form-item>
                <el-form-item label="身份证地址"><el-input v-model="dialogList.idNoAddress" :disabled="dialog1.title!=='添加'"></el-input></el-form-item>
                <el-form-item label="地址"><el-input v-model="dialogList.address"></el-input></el-form-item>
                <el-form-item label="文化水平"><el-select v-model="dialogList.educationalLevel" class="select200"><el-option v-for="item in codeData8" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="婚姻状态"><el-select v-model="dialogList.maritalStatus" class="select200"><el-option v-for="item in codeData9" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="浆员类型" v-if="dialog1.title!=='添加'"><el-select v-model="dialogList.jylxId" class="select200"><el-option v-for="item in codeData10" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="血浆类型" v-if="dialog1.title!=='添加'"><el-select v-model="dialogList.plasmaType" disabled class="select200"><el-option v-for="item in codeData11" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="血型" v-if="dialog1.title!=='添加'"><el-input v-model="dialogList.bloodTypeName" disabled></el-input></el-form-item>
                <el-form-item label="血管等级" v-if="dialog1.title!=='添加'"><el-select v-model="dialogList.veinGrade" class="select200"><el-option v-for="item in codeData13" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="浆员状态" v-if="dialog1.title!=='添加'"><el-select v-model="dialogList.providerState" disabled class="select200"><el-option v-for="item in codeData14" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item v-if="dialogList.providerState!='0'" label="拒绝原因"><el-input v-model="dialogList.refuseReason" disabled></el-input></el-form-item>
                <el-form-item v-if="dialogList.providerState!='0'" label="拒绝时间"><el-date-picker v-model="dialogList.refuseDate" disabled type="date" placeholder="选择日期"></el-date-picker></el-form-item>
                <el-form-item label="创建日期"><el-input v-model="dialogList.createDate" disabled></el-input></el-form-item>
                <el-form-item label="创建护士"><el-input v-model="dialogList.createNurseName" disabled></el-input></el-form-item>
                <el-form-item label="介绍人" prop="introducer"><el-input v-model="dialogList.introducer"></el-input></el-form-item>
                <el-form-item label="介绍人添加时间"><el-input v-model="dialogList.addIntroducerTime" disabled></el-input></el-form-item>
              </el-form>
            </el-col>
            <el-col :span="6">
              <div class="photoImg">
                  <img v-if="dialogList.photo" :src="dialogList.photo" class="avatar" />
              </div>
            </el-col>
          </el-row>
          <h3 class="dialog-plate-title"><span>身份证信息</span></h3>
          <el-row :gutter="20" style="margin-right: 0;" >
            <el-col :span="2">&nbsp;</el-col>
            <el-col :span="9">
              <el-upload class="identityCard"
                :action="idCardPhotoUrl"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload">
                <img v-if="dialogList.idCardPhoto" :src="dialogList.idCardPhoto" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon">身份证正面</i>
              </el-upload>
            </el-col>
            <el-col :span="2">&nbsp;</el-col>
            <el-col :span="9">
              <el-upload class="identityCard"
                :action="idCardPhotoUrl"
                :show-file-list="false"
                :on-success="handleAvatarSuccess1">
                <img v-if="dialogList.idCardPhoto1" :src="dialogList.idCardPhoto1" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon">身份证反面</i>
              </el-upload>
            </el-col>
            <el-col :span="2">&nbsp;</el-col>
        </el-row>
        <el-form :inline="true" :model="dialogList" label-width="100px" class="demo-ruleForm">
            <el-form-item label="身份证有效期"><el-date-picker v-model="dialogList.idCardValidDate" type="date" placeholder="选择日期"></el-date-picker></el-form-item>
            <el-form-item label="扫描时间"><el-input v-model="dialogList.idCardScanDate" disabled></el-input></el-form-item>
            <el-form-item label="证照记录人"><el-input v-model="dialogList.certificateRegisterName" disabled style="width: 190px;"></el-input></el-form-item>
        </el-form>
        <div>
          <el-button type="primary" @click="submitDialog">提交</el-button>
        </div>
        <div v-if="dialog1.title!=='添加'">
          <!-- 化检记录 -->
          <h3 class="dialog-plate-title"><span>化检记录</span></h3>
          <el-table :data="chemicalList" stripe border class="company-table" height="150px" style="width: 100%;">
              <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
              <el-table-column prop="recodeEndTime" label="采样时间" sortable min-width="200"></el-table-column>
              <el-table-column prop="inspectionRecodePersonName" label="化检记录人" sortable min-width="150"></el-table-column>
              <el-table-column prop="inspectionResultName" label="化检结果" sortable min-width="150"></el-table-column>
              <el-table-column fixed="right" label="操作" align="center" min-width="75">
                  <template slot-scope="scope">
                      <el-button  @click="dialog2Show('chemical',scope.row)" type="text" size="small">查看</el-button>
                  </template>
              </el-table-column>
          </el-table>
          <!-- 指纹记录 -->
          <h3 class="dialog-plate-title"><span>指纹记录</span></h3>
          <el-table :data="fingerPrintList" stripe border class="company-table" height="200px" style="width: 100%;" >
              <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
              <el-table-column prop="codeName" label="已录指纹" sortable min-width="200"></el-table-column>
          </el-table>
        </div>
        </el-tab-pane>
        <el-tab-pane label="胸片信息" name="second" v-if="dialog1.title!=='添加'">
          <el-button type="primary" @click="insertUpdateXp('insert')">新增</el-button>
          <el-table :data="tableChestData" stripe border class="company-table">
              <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
              <el-table-column prop="createDate" label="上传时间" sortable min-width="200"></el-table-column>
              <el-table-column prop="result" label="是否合格" :formatter="formatterIsTrain" sortable min-width="150"></el-table-column>
              <el-table-column prop="validDate" label="有效日期" sortable min-width="200"></el-table-column>
              <el-table-column fixed="right" label="操作" align="center" min-width="75">
                  <template slot-scope="scope">
                      <el-button  @click="insertUpdateXp('update',scope.row)" type="text" size="small">编辑</el-button>
                  </template>
              </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      </div>
      <div slot="footer">
      </div>
    </el-dialog>
    <el-dialog :title="dialog2.title" :visible.sync="dialog2.isShow" width="800px" top="60px" center :close-on-clcick-modal="false" class="dialog-form">
      <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
        <pulp-baseinfo :pulpInfo='chemicalInfo' v-if='dialog2.title==="化检详细信息"' :baseinfoDisabled='true'></pulp-baseinfo>
      </div>
    </el-dialog>
    <!-- 胸片信息 -->
    <el-dialog :title="dialog3.title" :visible.sync="dialog3.isShow" width="680px" top="70px" :close-on-clcick-modal="false" class="dialog-form">
      <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
        <el-form :inline="true" ref='chestForm' :model="dialogChestList" label-width="100px" class="demo-ruleForm" :rules="chestRules">
          <el-form-item label="检查单位" prop="hospital" ><el-input v-model="dialogChestList.hospital"></el-input></el-form-item>
          <el-form-item label="检查医生" prop="doctor" ><el-input v-model="dialogChestList.doctor"></el-input></el-form-item>
          <el-form-item label="检查备注" prop="remark" ><el-input v-model="dialogChestList.remark"></el-input></el-form-item>
          <el-form-item label="有效日期" prop="validDate" ><el-date-picker type="date" v-model="dialogChestList.validDate" placeholder="选择日期"></el-date-picker></el-form-item>
          <el-form-item label="是否合格"  prop="result" ><el-select v-model="dialogChestList.result"><el-option :value="'1'" label="是"></el-option><el-option :value="'0'" label="否"></el-option></el-select></el-form-item>
          <el-form-item label="上传时间"><el-input v-model="dialogChestList.createDate" disabled></el-input></el-form-item>
          <el-form-item label="胸片记录人"><el-input v-model="dialogChestList.crearorName" disabled></el-input></el-form-item>
          <el-form-item label="胸片" prop="photo" style="display:block;">
            <template slot="label">胸片</template>
            <div :span="19" class="avatar">
              <el-upload class="xpPhoto" :action="idCardPhotoUrl" :show-file-list="false" :on-success="handleAvatarChestSuccess" :before-upload="beforeAvatarUpload">
                <img v-if="dialogChestList.photo" :src="dialogChestList.photo" class="avatar" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
              </div>
          </el-form-item>
        </el-form>
        
      </div>
      <div slot="footer" style="text-align: right;">
          <el-button type="primary" @click="submitChestDialog">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import api from 'plugins/axios/api.js';
import regx from 'plugins/regx.js';
import pulpBaseinfo from 'views/operationManage/components/pulpBaseInfo.vue';
export default {
  components:{
    pulpBaseinfo,
  },
  data(){
    return {
      bloodTypeList:[],/**血型列表*/
      sexList:[],/**性别列表 */
      codeData8:[],/**文化水平列表*/
      codeData9:[],/** 婚姻状态列表*/
      codeData10:[],/** 浆员类型列表*/
      codeData11:[],/**血浆类型列表 */
      codeData13:[],/**血管类型列表 */
      codeData14:[],/**浆员状态 */
      tableData:[],/**表格列表 */
      chemicalList:[],/**浆员化检信息列表 */
      fingerPrintList:[],/**浆员化检指纹列表 */
      tableChestData :[],/**胸片列表 */
      loading:false,
      /**搜索参数 */
      searchList:{
        cardId:'',
        providerName:'',
        idNo:'',
        sex:'',
        idNoAddress:'',
        address:'',
        phone:'',
        bloodType:'',
        createStartTime:'',
        createEndTime:'',
        providerState:'',
        jsr:'',
        time:'',
      },
      /**分页参数 */
      pagination:{
        currentPage:1,
        pageSize:10,
        total:0
      },
      dialog1:{
        title:'',
        isShow:false
      },
      dialog2:{
        title:'',
        isShow:false
      },
      dialog3:{
        title:'',
        isShow:false
      },
      chemicalInfo:{},
      activeName:'first',
      dialogRules:{
        name: [
          { required: true, message: '请输入姓名', trigger: 'blur' },
          ],
        idNo:[
          { required: true, message: '请输入身份证号', trigger: 'blur' },
          { validator:regx.checkedID, trigger: 'blur' }
        ]
      },
      chestRules:{
        result:[ {required: true, message: '请选择是否合格', trigger: 'blur'}],
        hospital:[{required: true, message: '请输入检查单位', trigger: 'blur'}],
        doctor:[{required: true, message: '请输入检查医生', trigger: 'blur'}],
        remark:[{required: true, message: '请输入检查备注', trigger: 'blur'}],
        validDate:[{required: true, message: '请输入有效日期', trigger: 'blur'}],
        photo:[{required: true, message: '请上传胸片照片', trigger: 'blur'}],
      },
      dialogHeight2Table:[],
      dialogChestList:{},//胸片
      idCardPhotoUrl:api.idImgUpload(),
      dialogList:{}

    }
  },
  watch:{
    "dialogList.idNo":{/**监听身份证号码的输入 */
      handler(newIdNo, oldIdNo){
        let self = this;
      if(!regx.regexString.regxID.test(newIdNo)){
        self.dialogList.birthday = "";
        self.dialogList.age = "";
        self.dialogList.sex = "";
        return;
      }
      //获取出身日期
      self.dialogList.birthday = newIdNo.substring(6, 10) + "-" + newIdNo.substring(10, 12) + "-" + newIdNo.substring(12, 14);
        //获取年龄
      let myDate = new Date();
      let month = myDate.getMonth() + 1;
      let day = myDate.getDate();
      let age = myDate.getFullYear() - newIdNo.substring(6, 10) - 1;
      if (newIdNo.substring(10, 12) < month || newIdNo.substring(10, 12) == month && newIdNo.substring(12, 14) <= day) {
          age++;
      }
      self.dialogList.age = age;
      //获取性别
        if (parseInt(newIdNo.substr(16, 1)) % 2 == 1) {
          //男
          self.dialogList.sex='1';
        } else {
          //女
          self.dialogList.sex = "2";
        }
      }
    }
  },
  computed:{
    tableHeight(){
      return this.$store.state.clientHeight-184;
    }
  },
  created(){
    let self = this;
    self.getData();
    /*血型 */
    api.getCodeData(12).then(res=>{
        self.bloodTypeList=res.content;
    });
    /**浆员状态 */
    api.getCodeData(14).then(res=>{
        self.codeData14=res.content;
    });
    /**性别 */
    api.getCodeData(7).then(res=>{
      self.sexList=res.content;
    })
    api.getCodeData(8).then(res=>{
      self.codeData8= res.content;
    })
    api.getCodeData(9).then(res=>{
      self.codeData9 = res.content;
    })
    api.getCodeData(10).then(res=>{
      self.codeData10 = res.content;
    })
    api.getCodeData(11).then(res=>{
      self.codeData11= res.content;
    })
    api.getCodeData(13).then(res=>{
      self.codeData13 = res.content;
    })
  },
  mounted(){
  },
  methods:{
    getData(){/**建档记录查询 */
      let self = this;
      self.loading=true;
      let data={
        currentPage:self.pagination.currentPage,
        pageSize:self.pagination.pageSize,
        cardId:self.searchList.cardId,
        providerName:self.searchList.providerName,
        idNo:self.searchList.idNo,
        sex:self.searchList.sex,
        idNoAddress:self.searchList.idNoAddress,
        address:self.searchList.address,
        phone:self.searchList.phone,
        bloodType:self.searchList.bloodType,
        createStartTime:self.searchList.time ? self.timestampToTime(self.searchList.time[0],'yy-mm-dd') : "",
        createEndTime:self.searchList.time ? self.timestampToTime(self.searchList.time[1],'yy-mm-dd') : "",
        providerState:self.searchList.providerState,
        jsr:self.searchList.jsr,
      };
      api.providerInfo(data).then(res=>{
        self.loading=false;
        self.pagination.total = res.content.total;
        self.tableData = res.content.records;
      },error=>{
        self.loading=false;
      })
    },
    submitSearchData(){/**点击搜索 */
      this.pagination.currentPage=1;
      this.getData();
    },
    handleSizeChange(size){/**改变分页数据条数 */
      this.pagination.currentPage=1;
      this.pagination.pageSize=size;
      this.getData();
    },
    handleCurrentChange(current){/**改变分页页数*/
      this.pagination.currentPage=current;
      this.getData();
    },
    insertUpdateXp(type,row){
      let self = this;
      type==='insert'?'':row.result=String(row.result);
      self.dialogChestList = type==="insert" ? {
        crearor: '',
        crearorName: '',
        createDate: '',
        doctor: '',
        hospital: '',
        photo: '',
        providerNo: '',
        remark: '',
        result: '',
        validDate: ''
      } : row;
      self.dialog3.title=type==="insert"?'新增':'编辑';
      self.dialog3.isShow = true;
     
    },
    dialogShow(type,row){
      let self = this;
      self.dialog1.title = type==='insert'?'添加':'编辑';
      self.dialog1.isShow=true;
      self.activeName = 'first';
      if(type==='insert'){
         self.dialogList ={
          name:'',
          idNo:'',
          birthday:'',
          age:'',
          sex:'',
          idNoAddress:'',
          address:'',
          phone:'',
          educationalLevel:'',
          maritalStatus:'',
          introducer:'',
          idCardPhoto:'',
          idCardPhoto1:'',
          idCardValidDate:''
         }
      }else{
        self.dialogList =row;
        self.dialogList.jylxId = row.jylxId===null?'':String(row.jylxId);
        self.dialogList.maritalStatus= row.maritalStatus===null?'':String(row.maritalStatus);
        self.dialogList.educationalLevel= row.educationalLevel===null?'':String(row.educationalLevel);
        self.dialogList.veinGrade= row.veinGrade===null?'':String(row.veinGrade);
        self.dialogList.plasmaType= row.plasmaType===null?'':String(row.plasmaType);
        self.getchemicalList();
        self.getFingerPrintList();
      }
    },
    handleClick(tab, event){
      /**切换tab */ 
      if(tab.name==="second"){
        this.getXpList();
      }
    },
    getXpList(){
      let self = this;
      /**获取胸片信息列表 */
      api.xpList(self.dialogList.id).then(res=>{
          self.tableChestData = res.content;
      })
    },
    submitDialog(){/**点击dialog提交按钮 */
      let self = this;
      let postData = {
        address:self.dialogList.address,
        phone:self.dialogList.phone,
        educationalLevel:self.dialogList.educationalLevel,
        maritalStatus:self.dialogList.maritalStatus,
        idCardValidDate: self.dialogList.idCardValidDate?self.timestampToTime(self.dialogList.idCardValidDate,'yy-mm-dd'):'',
        introducer:self.dialogList.introducer,
        idCardPhoto:self.dialogList.idCardPhoto,
        idCardPhoto1:self.dialogList.idCardPhoto1
      }
      self.$refs.dialogRefs.validate((valid) => {
        if(!valid){
          return;
        }
        if(self.dialog1.title === '添加') {
          api.addUpdataProviderInfo('insertProviderInfo',
            Object.assign(postData,{
              name:self.dialogList.name,
              idNo:self.dialogList.idNo,
              birthday: self.dialogList.birthday?self.timestampToTime(self.dialogList.birthday,'yy-mm-dd'):'',
              age:self.dialogList.age,
              sex:self.dialogList.sex,
              idNoAddress:self.dialogList.idNoAddress
            })
          ).then(res=>{
            self.$message.success('浆员添加成功！')
            self.dialog1.isShow = false;
            self.getData();
          })
        }else{
          api.addUpdataProviderInfo('updateProviderInfo',self.dialogList).then(res=>{
            self.$message.success('浆员信息编辑成功！')
            self.dialog1.isShow = false;
            self.getData();
          })
        }
      })   
    },
    getchemicalList(){/**化检信息列表 */
      let self = this;
      self.chemicalList=[];
      api.getchemicalList(self.dialogList.id).then(res=>{
        self.chemicalList.push(res.content);
      })
    },
    getFingerPrintList(){/**化检信息列表 */
      let self = this;
      api.getFingerPrintList(self.dialogList.id).then(res=>{
        self.fingerPrintList=res.content;
      })
    },
    beforeAvatarUpload(file){/**身份证上传前 */
      const isJPG = file.type.substr(0,5) === 'image';
      const isLt10M = file.size / 1024 / 1024 < 10;
      if (!isJPG) {
          this.$message.error('只能上传图片!');
      }
      if (!isLt10M) {
          this.$message.error('上传头像图片大小不能超过 10MB!');
      }
      return isJPG && isLt10M
    },
    handleAvatarSuccess(response, file, fileList){
       this.dialogList.idCardPhoto = response;
    },
    handleAvatarSuccess1(response, file, fileList){
       this.dialogList.idCardPhoto1 = response;
    },
    handleAvatarChestSuccess(response, file, fileList){
      this.dialogChestList.photo = response;
    },
    dialog2Show(type,row){
      let self = this;
      self.dialog2.isShow = true;
      if(type==='chemical'){
        self.dialog2.title="化检详细信息";
        self.chemicalInfo = row;
      }
    },
    submitChestDialog(){/**提交胸片信息 */
      let self = this;
      let data = {
        crearor: self.dialogChestList.crearor,
        crearorName:self.dialogChestList.crearorName,
        createDate: self.dialogChestList.createDate,
        doctor: self.dialogChestList.doctor,
        hospital:self.dialogChestList.hospital,
        id: self.dialogChestList.id,
        providerNo: self.dialogList.id,
        photo: self.dialogChestList.photo,
        remark: self.dialogChestList.remark,
        result: self.dialogChestList.result,
        validDate: self.timestampToTime(self.dialogChestList.validDate,'yy-mm-dd hh:mm:ss') 
      }
      self.$refs.chestForm.validate((valid) => {
        if(!valid){
          return;
        }
        let type= self.dialog3.title==="新增"?'insert':'update';
        api.insertUpdataXp(type,data).then(res=>{
          self.$message.success(`${type==='insert'?'新增':'编辑'}成功`);
          self.dialog3.isShow=false;
          self.getXpList();
        })
      })
    }
  }
}
</script>
<style lang="stylus" scoped>
.photoImg
  height 275px
  img
    height 100%
.xpPhoto
  height 360px
  width 500px
  .avatar-uploader-icon:before
    margin-top 166px
</style>


